// 散点图
const mapFunAll = function mapFunAll (map, datalist) {
  map.clearMap()
  // 创建信息窗体的函数
  function createInfoWindow (data) {
    // 自定义弹窗内容赋值给content
    let content =
      ` <div class="close flexC JustifyContentSA" style="width:25.5625rem;height:14.375rem;background: url(${process.env.BASE_URL}img/11.png) no-repeat;background-size: 100% 100%;padding:1rem" >
          <div class="flex JustifyContentFE"><img src="${process.env.BASE_URL}img/10.png" onclick="window.vm.closeInfoWindow()" style="cursor: pointer;" /></div>
          <p class="font_s18 colorF" style="font-weight:bold;">${data.jgmc}</p>
          <p class="font_s16" style="color: #A2ADBF; font-weight:400;">
            <img class="verticM" style="height:1.125rem;" src="${process.env.BASE_URL}img/05.png" alt="" />
            &nbsp;&nbsp; 地址：
            <span class="Bold font_s16">${data.jgdz}</span>
          </p>
          <p><span class="Bold font_s16" style="color:#B0D5ED">法人代表：${data.fddbr}</span></p>
          <p><span class="Bold font_s16" style="color:#B0D5ED">机构代码：${data.jgdm}</span></p>
              <div class="flex" style="padding: 0.5rem 0rem ;">
                <div class="flexC JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                  <p>${data.fxfs}</p>
                  <p>${data.fxdj_srt}</p>
                </div>
                <div class="flex JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                  <p> ${data.fldj_srt} </p>
                </div>
               <div class="flexC JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                 <p>${data.xyfs}</p>
                 <p>${data.xydj_srt}</p>
               </div>
              </div>
           <p class="font_s16 cursor" onclick="window.vm.opencs(${data.fwjgid})" style="text-decoration:underline;color:rgba(114,246,248,1);line-height:2.5rem; font-weight:400;" >
             生命周期
           </p>
          <img src="${process.env.BASE_URL}${data.imgdz}" alt="" style="width: 8.875rem ;height:8.5rem; position: absolute; right: 0rem; bottom: 1.7rem;"/>
          </div>
        </div>
      `

    var info = document.createElement('div')
    info.className = 'custom-info input-card content-window-card'

    var middle = document.createElement('div')
    middle.className = 'info-middle'
    middle.innerHTML = content
    info.appendChild(middle)
    return info
  }
  // 创建点
  for (const elem of datalist.values()) {
    let arr = []
    arr.push(elem.jd)
    arr.push(elem.wd)
    elem.lnglat = arr
  }
  let infoWindow = new AMap.InfoWindow({
    isCustom: true,
    offset: new AMap.Pixel(160, -20)
  })

  for (let i = 0, marker; i < datalist.length; i++) {
    let icon = require('../assets/icon01.png')

    if ((datalist[i].fldj === 'A' || datalist[i].fldj === '一般监管') && datalist[i].fldj !== '') {
      icon = require('../assets/icon04.png')
      datalist[i].fldj = '一般监管'
    } else if ((datalist[i].fldj === 'B' || datalist[i].fldj === '关注监管') && datalist[i].fldj !== '') {
      icon = require('../assets/icon02.png')
      datalist[i].fldj = '关注监管'
    } else if ((datalist[i].fldj === 'C' || datalist[i].fldj === '重点监管') && datalist[i].fldj !== '') {
      icon = require('../assets/icon03.png')
      datalist[i].fldj = '重点监管'
    }
    if (datalist[i].fxfs === null) {
      datalist[i].fxfs = ''
    }
    if (datalist[i].fxdj_srt === null) {
      datalist[i].fxdj_srt = '无风险'
    }
    if (datalist[i].xyfs === null) {
      datalist[i].xyfs = ''
    }
    if (datalist[i].xydj_srt === null) {
      datalist[i].xydj_srt = ''
    }

    marker = new AMap.Marker({
      position: datalist[i].lnglat,
      icon: icon,
      map: map,
      title: datalist[i].jgmc
    })
    marker.content = createInfoWindow(datalist[i])
    marker.on('click', markerClick)
    marker.emit('click', {
      target: marker
    })
  }

  function markerClick (e) {
    infoWindow.setContent(e.target.content)
    if (e.pixel) { // 初始不打开弹窗
      infoWindow.open(map, e.target.getPosition())
    }
  }
  map.setFitView()
}

// 风险监管
const mapFunfxjg = function mapFun (map, datalist) {
  map.clearMap()

  function createInfoWindow (data) {
    let content =
      ` <div class="close flexC JustifyContentSA" style="width:25.5625rem;height:14.375rem;background: url(${process.env.BASE_URL}img/11.png) no-repeat;background-size: 100% 100%;padding:1rem" >
          <div class="flex JustifyContentFE"><img src="${process.env.BASE_URL}img/10.png" onclick="window.vm.closeInfoWindow()" style="cursor: pointer;" /></div>
          <p class="font_s18 colorF" style="font-weight:bold;">${data.jgmc}</p>
          <p class="font_s16" style="color: #A2ADBF; font-weight:400;">
            <img class="verticM" style="height:1.125rem;" src="${process.env.BASE_URL}img/05.png" alt="" />
            &nbsp;&nbsp; 地址：
            <span class="Bold font_s16">${data.jgdz}</span>
          </p>
          <p><span class="Bold font_s16" style="color:#B0D5ED">法人代表：${data.fddbr}</span></p>
          <p><span class="Bold font_s16" style="color:#B0D5ED">机构代码：${data.jgdm}</span></p>
              <div class="flex" style="padding: 0.5rem 0rem ;">
                <div class="flexC JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                  <p>${data.fxfs}</p>
                  <p>${data.fxdj_srt}</p>
                </div>
                <div class="flex JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                  <p> ${data.fldj_srt} </p>
                </div>
               <div class="flexC JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                 <p>${data.xyfs}</p>
                 <p>${data.xydj_srt}</p>
               </div>
              </div>
           <p class="font_s16 cursor" onclick="window.vm.opencs(${data.fwjgid})" style="text-decoration:underline;color:rgba(114,246,248,1);line-height:2.5rem; font-weight:400;" >
             生命周期
           </p>
          <img src="${process.env.BASE_URL}${data.imgdz}" alt="" style="width: 8.875rem ;height:8.5rem; position: absolute; right: 0rem; bottom: 1.7rem;"/>
          </div>
        </div>
      `
    var info = document.createElement('div')
    info.className = 'custom-info input-card content-window-card'

    var middle = document.createElement('div')
    middle.className = 'info-middle'
    middle.innerHTML = content
    info.appendChild(middle)
    return info
  }
  // 创建点
  for (const elem of datalist.values()) {
    let arr = []
    arr.push(elem.jd)
    arr.push(elem.wd)
    elem.lnglat = arr
  }
  let infoWindow = new AMap.InfoWindow({
    isCustom: true,
    offset: new AMap.Pixel(160, -20)
  })
  for (let i = 0, marker; i < datalist.length; i++) {
    let icon
    if (datalist[i].fxdj === 'A' && datalist[i].fxdj !== '') {
      icon = require('../assets/icon04.png')
    } else if (datalist[i].fxdj === 'B' && datalist[i].fxdj !== '') {
      icon = require('../assets/icon02.png')
    } else if (datalist[i].fxdj === 'C' && datalist[i].fxdj !== '') {
      icon = require('../assets/icon03.png')
    }

    if ((datalist[i].fldj === '一般监管' || datalist[i].fldj === 'A') && datalist[i].fldj !== '') {
      datalist[i].fldj = '一般监管'
    } else if ((datalist[i].fldj === '关注监管' || datalist[i].fldj === 'B') && datalist[i].fldj !== '') {
      datalist[i].fldj = '关注监管'
    } else if ((datalist[i].fldj === '重点监管' || datalist[i].fldj === 'C') && datalist[i].fldj !== '') {
      datalist[i].fldj = '重点监管'
    }

    if (datalist[i].fxfs === null) {
      datalist[i].fxfs = ''
    }
    if (datalist[i].fxdj_srt === null) {
      datalist[i].fxdj_srt = '无风险'
    }

    marker = new AMap.Marker({
      position: datalist[i].lnglat,
      icon: icon,
      map: map
    })
    marker.content = createInfoWindow(datalist[i])
    marker.on('click', markerClick)
    marker.emit('click', {
      target: marker
    })
  }

  function markerClick (e) {
    infoWindow.setContent(e.target.content)
    if (e.pixel) { // 初始不打开弹窗
      infoWindow.open(map, e.target.getPosition())
    }
  }
  map.setFitView()
}

// 信用监管
const mapFunxyjg = function mapFun (map, datalist) {
  map.clearMap()

  function createInfoWindow (data) {
    let content =
      ` <div class="close flexC JustifyContentSA" style="width:25.5625rem;height:14.375rem;background: url(${process.env.BASE_URL}img/11.png) no-repeat;background-size: 100% 100%;padding:1rem" >
          <div class="flex JustifyContentFE"><img src="${process.env.BASE_URL}img/10.png" onclick="window.vm.closeInfoWindow()" style="cursor: pointer;" /></div>
          <p class="font_s18 colorF" style="font-weight:bold;">${data.jgmc}</p>
          <p class="font_s16" style="color: #A2ADBF; font-weight:400;">
            <img class="verticM" style="height:1.125rem;" src="${process.env.BASE_URL}img/05.png" alt="" />
            &nbsp;&nbsp; 地址：
            <span class="Bold font_s16">${data.jgdz}</span>
          </p>
          <p><span class="Bold font_s16" style="color:#B0D5ED">法人代表：${data.fddbr}</span></p>
          <p><span class="Bold font_s16" style="color:#B0D5ED">机构代码：${data.jgdm}</span></p>
              <div class="flex" style="padding: 0.5rem 0rem ;">
                <div class="flexC JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                  <p>${data.fxfs}</p>
                  <p>${data.fxdj_srt}</p>
                </div>
                <div class="flex JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                  <p> ${data.fldj_srt} </p>
                </div>
               <div class="flexC JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                 <p>${data.xyfs}</p>
                 <p>${data.xydj_srt}</p>
               </div>
              </div>
           <p class="font_s16 cursor" onclick="window.vm.opencs(${data.fwjgid})" style="text-decoration:underline;color:rgba(114,246,248,1);line-height:2.5rem; font-weight:400;" >
             生命周期
           </p>
          <img src="${process.env.BASE_URL}${data.imgdz}" alt="" style="width: 8.875rem ;height:8.5rem; position: absolute; right: 0rem; bottom: 1.7rem;"/>
          </div>
        </div>
      `

    var info = document.createElement('div')
    info.className = 'custom-info input-card content-window-card'

    var middle = document.createElement('div')
    middle.className = 'info-middle'
    middle.innerHTML = content
    info.appendChild(middle)
    return info
  }
  // 创建点
  for (const elem of datalist.values()) {
    let arr = []
    arr.push(elem.jd)
    arr.push(elem.wd)
    elem.lnglat = arr
  }
  let infoWindow = new AMap.InfoWindow({
    isCustom: true,
    offset: new AMap.Pixel(160, -20)
  })
  for (let i = 0, marker; i < datalist.length; i++) {
    let icon
    if (datalist[i].xydj === 'A' && datalist[i].xydj !== '') {
      icon = require('../assets/icon04.png')
    } else if (datalist[i].xydj === 'B' && datalist[i].xydj !== '') {
      icon = require('../assets/icon02.png')
    } else if (datalist[i].xydj === 'C' && datalist[i].xydj !== '') {
      icon = require('../assets/icon03.png')
    }

    if ((datalist[i].fldj === '一般监管' || datalist[i].fldj === 'A') && datalist[i].fldj !== '') {
      datalist[i].fldj = '一般监管'
    } else if ((datalist[i].fldj === '关注监管' || datalist[i].fldj === 'B') && datalist[i].fldj !== '') {
      datalist[i].fldj = '关注监管'
    } else if ((datalist[i].fldj === '重点监管' || datalist[i].fldj === 'C') && datalist[i].fldj !== '') {
      datalist[i].fldj = '重点监管'
    }

    if (datalist[i].fxfs === null) {
      datalist[i].fxfs = ''
    }
    if (datalist[i].fxdj_srt === null) {
      datalist[i].fxdj_srt = '无风险'
    }

    marker = new AMap.Marker({
      position: datalist[i].lnglat,
      icon: icon,
      map: map
    })
    marker.content = createInfoWindow(datalist[i])
    marker.on('click', markerClick)
    marker.emit('click', {
      target: marker
    })
  }

  function markerClick (e) {
    infoWindow.setContent(e.target.content)
    if (e.pixel) { // 初始不打开弹窗
      infoWindow.open(map, e.target.getPosition())
    }
  }
  map.setFitView()
}

// 分类监管
const mapFunfljg = function mapFun (map, datalist) {
  map.clearMap()

  function createInfoWindow (data) {
    let content =
      ` <div class="close flexC JustifyContentSA" style="width:25.5625rem;height:14.375rem;background: url(${process.env.BASE_URL}img/11.png) no-repeat;background-size: 100% 100%;padding:1rem" >
          <div class="flex JustifyContentFE"><img src="${process.env.BASE_URL}img/10.png" onclick="window.vm.closeInfoWindow()" style="cursor: pointer;" /></div>
          <p class="font_s18 colorF" style="font-weight:bold;">${data.jgmc}</p>
          <p class="font_s16" style="color: #A2ADBF; font-weight:400;">
            <img class="verticM" style="height:1.125rem;" src="${process.env.BASE_URL}img/05.png" alt="" />
            &nbsp;&nbsp; 地址：
            <span class="Bold font_s16">${data.jgdz}</span>
          </p>
          <p><span class="Bold font_s16" style="color:#B0D5ED">法人代表：${data.fddbr}</span></p>
          <p><span class="Bold font_s16" style="color:#B0D5ED">机构代码：${data.jgdm}</span></p>
              <div class="flex" style="padding: 0.5rem 0rem ;">
                <div class="flexC JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                  <p>${data.fxfs}</p>
                  <p>${data.fxdj_srt}</p>
                </div>
                <div class="flex JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                  <p> ${data.fldj_srt} </p>
                </div>
               <div class="flexC JustifyContentC AlignItemsC" style="border:1px solid #72F6F8;box-sizing:border-box;width:4.875rem;height:3.75rem;text-align:center;color:#72F6F8; margin: 0px 5px;">
                 <p>${data.xyfs}</p>
                 <p>${data.xydj_srt}</p>
               </div>
              </div>
           <p class="font_s16 cursor" onclick="window.vm.opencs(${data.fwjgid})" style="text-decoration:underline;color:rgba(114,246,248,1);line-height:2.5rem; font-weight:400;" >
             生命周期
           </p>
          <img src="${process.env.BASE_URL}${data.imgdz}" alt="" style="width: 8.875rem ;height:8.5rem; position: absolute; right: 0rem; bottom: 1.7rem;"/>
          </div>
        </div>
      `

    var info = document.createElement('div')
    info.className = 'custom-info input-card content-window-card'

    var middle = document.createElement('div')
    middle.className = 'info-middle'
    middle.innerHTML = content
    info.appendChild(middle)
    return info
  }
  // 创建点
  for (const elem of datalist.values()) {
    let arr = []
    arr.push(elem.jd)
    arr.push(elem.wd)
    elem.lnglat = arr
  }
  let infoWindow = new AMap.InfoWindow({
    isCustom: true,
    offset: new AMap.Pixel(160, -20)
  })
  for (let i = 0, marker; i < datalist.length; i++) {
    let icon
    if ((datalist[i].fldj === 'A' || datalist[i].fldj === '一般监管') && datalist[i].fldj !== '') {
      icon = require('../assets/icon04.png')
      datalist[i].fldj = '一般监管'
    } else if ((datalist[i].fldj === 'B' || datalist[i].fldj === '关注监管') && datalist[i].fldj !== '') {
      icon = require('../assets/icon02.png')
      datalist[i].fldj = '关注监管'
    } else if ((datalist[i].fldj === 'C' || datalist[i].fldj === '重点监管') && datalist[i].fldj !== '') {
      icon = require('../assets/icon03.png')
      datalist[i].fldj = '重点监管'
    }
    if (datalist[i].fxfs === null) {
      datalist[i].fxfs = ''
    }
    if (datalist[i].fxdj_srt === null) {
      datalist[i].fxdj_srt = '无风险'
    }

    marker = new AMap.Marker({
      position: datalist[i].lnglat,
      icon: icon,
      map: map
    })
    marker.content = createInfoWindow(datalist[i])
    marker.on('click', markerClick)
    marker.emit('click', {
      target: marker
    })
  }

  function markerClick (e) {
    infoWindow.setContent(e.target.content)
    if (e.pixel) { // 初始不打开弹窗
      infoWindow.open(map, e.target.getPosition())
    }
  }
  map.setFitView()
}

export {
  mapFunAll,
  mapFunfxjg,
  mapFunxyjg,
  mapFunfljg
}
